package com.test.daily.leetcode.y2022.m06.day0614.v03;

import java.util.Comparator;
import java.util.PriorityQueue;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/6/15 下午 10:53
 * @version: 1.0
 */
public class Solution {
    public int smallestDistancePair(int[] nums, int k) {
        PriorityQueue<Integer> pq = new PriorityQueue<>(k,new MyComparator());
        int N = nums.length;
        for (int i = 0; i < N -1; i++) {
            for (int j = i+1; j < N; j++) {
                pq.add(Math.abs(nums[i] - nums[j]));
            }
        }
        return pq.poll();
    }
    public static class MyComparator implements Comparator<Integer>{
        @Override
        public int compare(Integer o1, Integer o2) {
            return o1.compareTo(o2);
        }
    }
}
